home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / ADSP.h next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  10.2 KB  |  277 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        ADSP.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __ADSP__
  18. #define __ADSP__
  19.  
  20.  
  21. #ifndef __ERRORS__
  22. #include <Errors.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __APPLETALK__
  27. #include <AppleTalk.h>
  28. #endif
  29. /*    #include <Types.h>                                            */
  30. /*    #include <OSUtils.h>                                        */
  31. /*        #include <MixedMode.h>                                    */
  32. /*        #include <Memory.h>                                        */
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37.  
  38. #if GENERATINGPOWERPC
  39. #pragma options align=mac68k
  40. #endif
  41.  
  42. #ifdef __CFM68K__
  43. #pragma lib_export on
  44. #endif
  45.  
  46.  
  47. enum {
  48.     dspInit                        = 255,                            /* create a new connection end */
  49.     dspRemove                    = 254,                            /* remove a connection end */
  50.     dspOpen                        = 253,                            /* open a connection */
  51.     dspClose                    = 252,                            /* close a connection */
  52.     dspCLInit                    = 251,                            /* create a connection listener */
  53.     dspCLRemove                    = 250,                            /* remove a connection listener */
  54.     dspCLListen                    = 249,                            /* post a listener request */
  55.     dspCLDeny                    = 248,                            /* deny an open connection request */
  56.     dspStatus                    = 247,                            /* get status of connection end */
  57.     dspRead                        = 246,                            /* read data from the connection */
  58.     dspWrite                    = 245,                            /* write data on the connection */
  59.     dspAttention                = 244                            /* send an attention message */
  60. };
  61.  
  62. enum {
  63.     dspOptions                    = 243,                            /* set connection end options */
  64.     dspReset                    = 242,                            /* forward reset the connection */
  65.     dspNewCID                    = 241,                            /* generate a cid for a connection end */
  66. /* connection opening modes */
  67.     ocRequest                    = 1,                            /* request a connection with remote */
  68.     ocPassive                    = 2,                            /* wait for a connection request from remote */
  69.     ocAccept                    = 3,                            /* accept request as delivered by listener */
  70.     ocEstablish                    = 4,                            /* consider connection to be open */
  71. /* connection end states */
  72.     sListening                    = 1,                            /* for connection listeners */
  73.     sPassive                    = 2,                            /* waiting for a connection request from remote */
  74.     sOpening                    = 3,                            /* requesting a connection with remote */
  75.     sOpen                        = 4,                            /* connection is open */
  76.     sClosing                    = 5,                            /* connection is being torn down */
  77.     sClosed                        = 6,                            /* connection end state is closed */
  78. /* client event flags */
  79.     eClosed                        = 0x80,                            /* received connection closed advice */
  80.     eTearDown                    = 0x40,                            /* connection closed due to broken connection */
  81.     eAttention                    = 0x20,                            /* received attention message */
  82.     eFwdReset                    = 0x10,                            /* received forward reset advice */
  83. /* miscellaneous constants */
  84.     attnBufSize                    = 570,                            /* size of client attention buffer */
  85.     minDSPQueueSize                = 100                            /* Minimum size of receive or send Queue */
  86. };
  87.  
  88. /* connection control block */
  89. struct TRCCB {
  90.     struct TRCCB                    *ccbLink;                    /* link to next ccb */
  91.     UInt16                            refNum;                        /* user reference number */
  92.     UInt16                            state;                        /* state of the connection end */
  93.     UInt8                            userFlags;                    /* flags for unsolicited connection events */
  94.     UInt8                            localSocket;                /* socket number of this connection end */
  95.     AddrBlock                        remoteAddress;                /* internet address of remote end */
  96.     UInt16                            attnCode;                    /* attention code received */
  97.     UInt16                            attnSize;                    /* size of received attention data */
  98.     void                            *attnPtr;                    /* ptr to received attention data */
  99.     UInt8                            reserved[220];                /* for adsp internal use */
  100. };
  101. typedef struct TRCCB TRCCB;
  102.  
  103. typedef TRCCB *TPCCB;
  104.  
  105. typedef struct DSPParamBlock DSPParamBlock, *DSPPBPtr;
  106.  
  107. /*
  108.         ADSPConnectionEventProcPtr uses register based parameters on the 68k and cannot
  109.         be written in or called from a high-level language without the help of
  110.         mixed mode or assembly glue.
  111.  
  112.         In:
  113.          => sourceCCB       A1.L
  114. */
  115. /*
  116.         ADSPCompletionProcPtr uses register based parameters on the 68k and cannot
  117.         be written in or called from a high-level language without the help of
  118.         mixed mode or assembly glue.
  119.  
  120.         In:
  121.          => thePBPtr        A0.L
  122. */
  123.  
  124. #if GENERATINGCFM
  125. typedef UniversalProcPtr ADSPConnectionEventUPP;
  126. typedef UniversalProcPtr ADSPCompletionUPP;
  127. #else
  128. typedef Register68kProcPtr ADSPConnectionEventUPP;
  129. typedef Register68kProcPtr ADSPCompletionUPP;
  130. #endif
  131.  
  132. struct TRinitParams {
  133.     TPCCB                            ccbPtr;                        /* pointer to connection control block */
  134.     ADSPConnectionEventUPP            userRoutine;                /* client routine to call on event */
  135.     UInt16                            sendQSize;                    /* size of send queue (0..64K bytes) */
  136.     void                            *sendQueue;                    /* client passed send queue buffer */
  137.     UInt16                            recvQSize;                    /* size of receive queue (0..64K bytes) */
  138.     void                            *recvQueue;                    /* client passed receive queue buffer */
  139.     void                            *attnPtr;                    /* client passed receive attention buffer */
  140.     UInt8                            localSocket;                /* local socket number */
  141.     UInt8                            filler1;                    /* filler for proper byte alignment */
  142. };
  143. typedef struct TRinitParams TRinitParams, *TRinitParamsPtr;
  144.  
  145. struct TRopenParams {
  146.     UInt16                            localCID;                    /* local connection id */
  147.     UInt16                            remoteCID;                    /* remote connection id */
  148.     AddrBlock                        remoteAddress;                /* address of remote end */
  149.     AddrBlock                        filterAddress;                /* address filter */
  150.     UInt32                            sendSeq;                    /* local send sequence number */
  151.     UInt16                            sendWindow;                    /* send window size */
  152.     UInt32                            recvSeq;                    /* receive sequence number */
  153.     UInt32                            attnSendSeq;                /* attention send sequence number */
  154.     UInt32                            attnRecvSeq;                /* attention receive sequence number */
  155.     UInt8                            ocMode;                        /* open connection mode */
  156.     UInt8                            ocInterval;                    /* open connection request retry interval */
  157.     UInt8                            ocMaximum;                    /* open connection request retry maximum */
  158.     UInt8                            filler2;                    /* filler for proper byte alignment */
  159. };
  160. typedef struct TRopenParams TRopenParams, *TRopenParamsPtr;
  161.  
  162. struct TRcloseParams {
  163.     UInt8                            abort;                        /* abort connection immediately if non-zero */
  164.     UInt8                            filler3;                    /* filler for proper byte alignment */
  165. };
  166. typedef struct TRcloseParams TRcloseParams, *TRcloseParamsPtr;
  167.  
  168. struct TRioParams {
  169.     UInt16                            reqCount;                    /* requested number of bytes */
  170.     UInt16                            actCount;                    /* actual number of bytes */
  171.     void                            *dataPtr;                    /* pointer to data buffer */
  172.     UInt8                            eom;                        /* indicates logical end of message */
  173.     UInt8                            flush;                        /* send data now */
  174. };
  175. typedef struct TRioParams TRioParams, *TRioParamsPtr;
  176.  
  177. struct TRattnParams {
  178.     UInt16                            attnCode;                    /* client attention code */
  179.     UInt16                            attnSize;                    /* size of attention data */
  180.     void                            *attnData;                    /* pointer to attention data */
  181.     UInt8                            attnInterval;                /* retransmit timer in 10-tick intervals */
  182.     UInt8                            filler4;                    /* filler for proper byte alignment */
  183. };
  184. typedef struct TRattnParams TRattnParams, *TRattnParamsPtr;
  185.  
  186. struct TRstatusParams {
  187.     TPCCB                            statusCCB;                    /* pointer to ccb */
  188.     UInt16                            sendQPending;                /* pending bytes in send queue */
  189.     UInt16                            sendQFree;                    /* available buffer space in send queue */
  190.     UInt16                            recvQPending;                /* pending bytes in receive queue */
  191.     UInt16                            recvQFree;                    /* available buffer space in receive queue */
  192. };
  193. typedef struct TRstatusParams TRstatusParams, *TRstatusParamsPtr;
  194.  
  195. struct TRoptionParams {
  196.     UInt16                            sendBlocking;                /* quantum for data packets */
  197.     UInt8                            sendTimer;                    /* send timer in 10-tick intervals */
  198.     UInt8                            rtmtTimer;                    /* retransmit timer in 10-tick intervals */
  199.     UInt8                            badSeqMax;                    /* threshold for sending retransmit advice */
  200.     UInt8                            useCheckSum;                /* use ddp packet checksum */
  201. };
  202. typedef struct TRoptionParams TRoptionParams, *TRoptionParamsPtr;
  203.  
  204. struct TRnewcidParams {
  205.     UInt16                            newcid;                        /* new connection id returned */
  206. };
  207. typedef struct TRnewcidParams TRnewcidParams, *TRnewcidParamsPtr;
  208.  
  209. struct DSPParamBlock {
  210.     struct QElem                    *qLink;
  211.     short                            qType;
  212.     short                            ioTrap;
  213.     Ptr                                ioCmdAddr;
  214.     ADSPCompletionUPP                ioCompletion;
  215.     OSErr                            ioResult;
  216.     StringPtr                        ioNamePtr;
  217.     short                            ioVRefNum;
  218.     short                            ioCRefNum;                    /* adsp driver refNum */
  219.     short                            csCode;                        /* adsp driver control code */
  220.     long                            qStatus;                    /* adsp internal use */
  221.     short                            ccbRefNum;
  222.     union {
  223.         TRinitParams                    initParams;                /*dspInit, dspCLInit*/
  224.         TRopenParams                    openParams;                /*dspOpen, dspCLListen, dspCLDeny*/
  225.         TRcloseParams                    closeParams;            /*dspClose, dspRemove*/
  226.         TRioParams                        ioParams;                /*dspRead, dspWrite*/
  227.         TRattnParams                    attnParams;                /*dspAttention*/
  228.         TRstatusParams                    statusParams;            /*dspStatus*/
  229.         TRoptionParams                    optionParams;            /*dspOptions*/
  230.         TRnewcidParams                    newCIDParams;            /*dspNewCID*/
  231.     } u;
  232. };
  233.  
  234. enum {
  235.     uppADSPConnectionEventProcInfo = kRegisterBased
  236.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA1, SIZE_CODE(sizeof(TPCCB))),
  237.     uppADSPCompletionProcInfo = kRegisterBased
  238.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(DSPPBPtr)))
  239. };
  240.  
  241. #if GENERATINGCFM
  242. #define NewADSPConnectionEventProc(userRoutine)        \
  243.         (ADSPConnectionEventUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPConnectionEventProcInfo, GetCurrentArchitecture())
  244. #define NewADSPCompletionProc(userRoutine)        \
  245.         (ADSPCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPCompletionProcInfo, GetCurrentArchitecture())
  246. #else
  247. #define NewADSPConnectionEventProc(userRoutine)        \
  248.         ((ADSPConnectionEventUPP) (userRoutine))
  249. #define NewADSPCompletionProc(userRoutine)        \
  250.         ((ADSPCompletionUPP) (userRoutine))
  251. #endif
  252.  
  253. #if GENERATINGCFM
  254. #define CallADSPConnectionEventProc(userRoutine, sourceCCB)        \
  255.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppADSPConnectionEventProcInfo, (sourceCCB))
  256. #define CallADSPCompletionProc(userRoutine, thePBPtr)        \
  257.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppADSPCompletionProcInfo, (thePBPtr))
  258. #else
  259. /* (*ADSPConnectionEventProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  260. /* (*ADSPCompletionProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  261. #endif
  262.  
  263.  
  264. #ifdef __CFM68K__
  265. #pragma lib_export off
  266. #endif
  267.  
  268. #if GENERATINGPOWERPC
  269. #pragma options align=reset
  270. #endif
  271.  
  272. #ifdef __cplusplus
  273. }
  274. #endif
  275.  
  276. #endif /* __ADSP__ */
  277.